<?php

namespace App\Http\Controllers\Home;

use App\Http\Model\Article;
use App\Http\Model\Links;
use App\Http\Model\Navs;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\View;

class CommonController extends Controller
{
    //导航栏内容共享
    public function __construct()
    {
        $navs = Navs::orderBy('nav_order','asc')->get();
        View::share('navs', $navs);

        //3.最新的文章8篇
        $new = Article::orderBy('art_time','desc')->take(8)->get(['art_id','art_title','art_thumb','art_description']);
        //4.点击排行
        $hot = Article::orderBy('art_view','desc')->take(5)->get(['art_id','art_title']);
        //5.友情链接
        $link = Links::orderBy('link_order','desc')->get();

        View::share('new', $new);
        View::share('hot', $hot);
        View::share('link', $link);
    }
}
